﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Mobile
{
    public partial class Mobile : System.Web.UI.Page
    {
        List<Producer> producers = new List<Producer>()
            {
                new Producer() { Name = "Audi", Models = new List<string>() { "A1", "A2", "A3", "A4" } },
                new Producer() { Name = "BMW", Models = new List<string>() { "B1", "B2", "B3", "B4" } },
                new Producer() { Name = "Mercedes", Models = new List<string>() { "M1", "M2", "M3", "M4" } }
            };

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CarProducer.DataSource = producers;
                CarProducer.DataBind();
                Model.DataSource = producers[0].Models;
                Model.DataBind();                
            }
        }

        protected void Producer_Changed(object sender, EventArgs e)
        {
            int selectedproducer = CarProducer.SelectedIndex;
            Model.DataSource = producers[selectedproducer].Models;
            Model.DataBind();
        }
    }
}